//
//  TTImageDingzhiCountViewCell.m
//  TaoTuo
//
//  Created by 刘广 on 2020/3/27.
//  Copyright © 2020 刘广. All rights reserved.
//

#import "TTImageDingzhiCountViewCell.h"

@interface TTImageDingzhiCountViewCell ()

@property (nonatomic, strong) UIImageView *imageView;
@property (nonatomic, strong) UILabel *countLabel;

@end

@implementation TTImageDingzhiCountViewCell

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        UIView *bgView = [[UIView alloc] initWithFrame:CGRectMake(0, 10, self.width - 10, self.height - 10)];
        bgView.backgroundColor = UIColorHex(#F0F4F7);
        bgView.layer.cornerRadius = 5;
        bgView.layer.masksToBounds = YES;
        [self.contentView addSubview:bgView];
        
        _imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, bgView.width, bgView.height - 30)];
        _imageView.backgroundColor = UIColorHex(f2f2f2);
        _imageView.contentMode = UIViewContentModeCenter;
        [bgView addSubview:_imageView];
        
        _countLabel = [UILabel labelTextCenterWithTitle:@"" color:UIColorHex(#DEDEDE) fontSize:10];
        _countLabel.frame = CGRectMake(0, _imageView.bottom, bgView.width, 30);
        [bgView addSubview:_countLabel];
        
        self.countLabel.backgroundColor = UIColorHex(f2f2f2);
        
    }
    return self;
}

- (void)setModel:(TTImageDingzhiModel *)model
{
    _model = model;
    self.imageView.image = [UIImage imageNamed:model.imageName];
    if (model.hintStr.length > 0) {
        self.countLabel.text = model.hintStr;
    } else {
        self.countLabel.text = [NSString stringWithFormat:@"还可上传%ld张", model.count];
    }

}

@end
